<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(function () {

            //页头搜索功能
            $("#searchBtn").click(function () {
                var keyword = $("#search").val();
                if (keyword != null & keyword != "") {
                    window.location.href = "/searchPage.html?keyword=" + keyword + "&type=2";
                } else {
                    $(document).dialog({
                        titleText: '温馨提示',
                        content: '搜索内容不能为空!',
                    });
                }
            });


            //每月推荐回显
            $.get(baseUrl + "travelCommonds", {type: 2}, function (data) {
                $("#travelsCommends").renderValues(data, {
                    'getHref': getHref
                });
                $(".carousel-item:first").addClass('active');
            });
           


            var currentPage = 1;//当前页
            var totalPage;//总页数
            var travelArr = [];//存放页面的容器
            var loading = false;//判定请求数据是否传完的标记


            function query() {
                if (loading) {//如果是加载状态就不发送请求
                    return;
                }
                loading = true;//进入加载状态
                $.get(baseUrl + "travels", {currentPage: currentPage}, function (data) {
                    //每次查询都要把页面信息合并到容器中
                    $.merge(travelArr, data.list);
                    var json = {list: travelArr};
                    $("#allTravels").renderValues(json, {
                        'getHref': getHref
                    });

                    //没查询一次当前页数加1
                    currentPage++;
                    //获取数据的总页数
                    totalPage = data.pages;
                    loading = false;//加载完成后把状态改成可以发送请求的状态
                });

            }

            $(function () {
                //默认自动查询第一页数据
                query();
                $(window).scroll(function () {
                    //如果页面的滚动长度加窗口长度等于页面的总长度时 发送请求查询下一页数据
                    if ($(document).scrollTop() + $(window).height() >= $(document).height() - 50) {//提前五十像素发送请求
                        //当前页小于总页数的时候才查询
                        if (currentPage <= totalPage) {
                            query();
                        } else {
                            $(document).dialog({
                                type: 'notice',
                                infoIcon: '../img/icon/loading.gif',
                                infoText: '不要拉了,再拉就出屎了!',
                                autoClose: 1000
                            });
                        }

                    }
                })
            })


        })
    </script>

</head>

<body>

<div class="search-head">
    <div class="row nav-search">
        <div class="col-1">
            <a href="/index.html" style="position: absolute;top: 3px;left: 22px;">
                <span><i class="fa fa-chevron-left fa-2x" style="color: white;"></i></span>
            </a>
        </div>
        <div class="col-9">
            <div class="input-group-sm search">
                <input id="search" class="form-control" placeholder="搜游记">
            </div>
        </div>
        <div class="col-1">
            <i class="fa fa-search" id="searchBtn"
               style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%">
            </i>
        </div>
    </div>
</div>

<div class="container">

    <h6>每月冠军游记</h6>
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
        <div id="travelsCommends" class="carousel-inner">
            <div render-loop="list">
                <div class="carousel-item ">
                    <div class="border commend">
                        <a data-url="travelContent.html?id=" render-fun="getHref" render-key="list.travelId">
                            <img render-src="list.coverUrl" width="100%" height="200px">
                            <h1 render-html="list.title"> </h1>
                            <small render-html="list.placeName"></small>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
    </div>
</div>

<div class="container">
    <h6>全部游记</h6>
    <div id="allTravels">
        <div render-loop="list">
            <div class="row detail">
                <div class="col">
                    <a data-url="travelContent.html?id=" render-fun="getHref" render-key="list.id">
                        <h4 render-html="list.title"></h4>
                    </a>
                    <p>
                        <a data-url="userProfiles.html?id=" render-fun="getHref" render-key="list.author.id">
                            <img class="rounded-circle head-img" render-src="list.author.headImgUrl">
                            <span render-html="list.author.nickName"></span> </a> 在
                        <span class="addr" render-html="list.place.name"></span>

                    </p>
                    <p>
                        <i class="fa fa-eye fa-fw"></i>
                        <span id="browserNum" render-html="list.browseNum" >0</span>
                        <i class="fa fa-commenting fa-fw"></i>
                        <span id="commentNum" render-html="list.commentNum">0</span>
                    </p>
                    <p>
                        发布时间:<span  render-html="list.releaseTime"></span>
                    </p>
                </div>
                <div class="col bigimg">
                    <a data-url="travelContent.html?id=" render-fun="getHref" render-key="list.id">
                        <img render-src="list.coverUrl">
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>


</body>

</html>